Skip to content

Module Architecture

flowchart TD
    SUBSMOD["sadeem_subscription\nSubscription Base"]
    CF["sadeem_cloudflare\nCloudflare"]

    GRP["sadeem.dbfilter.server.group\ngroup of DBFilter servers\nshared defaults"]
    GRPS["sadeem.dbfilter.server.group.servers\nserver-to-group mapping\nrelation table"]
    DBF["sadeem.dbfilter.server\nshared Odoo instance\nDB filter routing"]
    SUB["sadeem.subscription (inherit)\ndbfilter type · server ref\ndatabase name"]
    PROD["product.template (inherit)\nDBFilter server group\nfor plan assignment"]
    INV["account.move (inherit)\ntrigger subscription actions\non invoice payment"]

    SUBSMOD --> SUB
    CF --> SUB

    GRP --> GRPS
    GRPS --> DBF
    SUB --> DBF
    SUB --> GRP
    PROD --> GRP
    INV --> SUB

    DBF --> A1([action_test_connection\ntest slave connectivity])
    DBF --> A2([action_create_database\ncreate DB on shared Odoo server])
    DBF --> A3([get_best_server\nselect server by capacity])

    GRP --> A4([_apply_dbfilter_server_group_defaults\ncopy Nginx · Cloudflare · domain to subscription])

    SUB --> A5([action_confirm override\nauto-provision DB + Nginx + DNS])
    SUB --> A6([action_drop_db override\ndrop database on DBFilter server])
    SUB --> A7([action_cancel override\nclean up DB and DNS resources])
    SUB --> A8([action_stop override\ndisable Nginx proxy host])
    SUB --> A9([action_start override\nre-enable Nginx proxy host])

    EXT[/DBFilter Slave Agent\nremote Odoo slave instance/]
    A2 --> EXT
    A3 --> EXT

Module Description

DB Filter SAAS - Provides database-filter-based SAAS infrastructure. Enables automated creation and management of multi-tenant Odoo instances on dedicated DB Filter servers with support for load balancing via server groups and automatic subscription creation from invoices.

Dependencies

  • sadeem_cloudflare
  • sadeem_subscription
  • product

Menus

SAAS Management
└─ Infrastructure
    └─ DbFilter SAAS
        ├─ DBfilter Servers
        ├─ DBfilter Server Groups
        ├─ Packages
        └─ Modules

Subscription Type

This module adds the dbfilter subscription type. When selected, subscriptions are deployed as databases on a shared Odoo instance using the DB Filter mechanism for routing.

Key Fields

DBFilter Server (sadeem.dbfilter.server)

Field Type Description
odoo_url Char Full public URL of the shared Odoo instance
ip Char IP address of the server (required)
odoo_http_port Integer Odoo HTTP port (default: 8069)
odoo_websocket_port Integer Websocket port (default: 8072)
master_password Char Odoo database manager master password
create_db_path Char API path for database creation (default: /web/database/create)
drop_db_path Char API path for dropping databases
backup_db_path Char API path for database backup
restore_db_path Char API path for database restore
custom_db_routes Boolean Whether the server uses custom database manager routes
domain_for_new_sub Char Base domain for generating subscription subdomains
subdomain_start Char Prefix for generated subdomains
default_lang Char Default language code for new databases (default: ar_001)
default_country_code Char Default country code (default: sa)
state Selection Server status: draft, confirm, cancel
expected_capacity Integer Max number of subscriptions this server can handle
subscriptions_count Integer Computed: total subscriptions linked to this server
active_subscriptions_count Integer Computed: active (running) subscriptions
available_capacity Integer Computed: expected_capacity − subscriptions_count
cloudflare_account_id Many2one Cloudflare connector for DNS management
cloudflare_domain_zone_id Char Cloudflare Zone ID
cloudflare_create_record Boolean Auto-create DNS records for new subscriptions
cloudflare_proxied_record Boolean Whether DNS records should be Cloudflare-proxied
nginx_proxy_server_id Many2one NPM connector for this server
nginx_default_cert_id Integer Default SSL certificate ID
backup_server_id Many2one Remote backup server

DBFilter Server Group (sadeem.dbfilter.server.group)

Field Type Description
odoo_version Float Odoo version for servers in this group (required)
server_ids One2many Member servers via the join table
select_server_by Selection Selection strategy: sequence or used (low usage)
country_group Many2one Country group filter for server assignment

Subscription — DBFilter additions (sadeem.subscription inherit)

Field Type Description
saas_subscription_type Selection Extended with ('dbfilter', 'DbFilter') value
dbfilter_server Many2one The shared Odoo server this subscription runs on
dbfilter_saas_server_group Many2one Server group used to auto-select the best server
dbfilter_subscription_password Char First user password (generated at creation, read-only)

Lifecycle & States

DBFilter Server States

State Meaning
draft Server not yet verified
confirm Server is active and accepting subscriptions
cancel Server deactivated

Transitions: - draftconfirm: action_confirm - confirmdraft: action_reset_draft - Any → cancel: action_cancel

Subscription Provisioning (DBFilter)

  • action_confirm override: If dbfilter_saas_server_group is set, calls _apply_dbfilter_server_group_defaults() to auto-assign the best server and copy all defaults (IP, ports, domain, Cloudflare, Nginx) from the server group.
  • action_run_subscription override: Creates the database on the DBFilter server via HTTP call to the shared Odoo instance; then provisions DNS and Nginx as in the base module.

Key Actions

Action Model Description
action_confirm sadeem.dbfilter.server Verifies server connectivity; moves to confirm state
action_reset_draft sadeem.dbfilter.server Resets to draft
action_cancel sadeem.dbfilter.server Cancels the server
action_test_connection sadeem.dbfilter.server Tests HTTP connectivity to the shared Odoo instance
action_create_database sadeem.dbfilter.server Creates a new database on the shared Odoo instance
get_best_server sadeem.dbfilter.server.group Selects the best available server by sequence or lowest usage
_apply_dbfilter_server_group_defaults sadeem.subscription (inherit) Copies server defaults (domain, Nginx, Cloudflare, ports) from the selected group server to the subscription
action_confirm (override) sadeem.subscription Applies server group defaults then calls base action_confirm
action_run_subscription (override) sadeem.subscription Creates the database on the DBFilter server, then provisions DNS + Nginx
action_drop_db (override) sadeem.subscription Drops the database on the DBFilter server
action_cancel (override) sadeem.subscription Cleans up DB and DNS resources on the DBFilter server
action_stop (override) sadeem.subscription Disables the Nginx proxy host
action_start (override) sadeem.subscription Re-enables the Nginx proxy host

Warnings & Important Notes

  • Server deletion blocked: Cannot delete a sadeem.dbfilter.server while it has active linked subscriptions — raises ValidationError.
  • No servers in group: get_best_server raises ValidationError if the server group has no member servers.
  • Server must be confirmed: The dbfilter_server field domain filter restricts selection to servers with state = 'confirm'.
  • Auto-assignment from group: When dbfilter_saas_server_group is set, action_confirm automatically overwrites server, domain, Cloudflare, and Nginx settings from the group's best server — manual overrides will be replaced.
  • Capacity tracking: The server's available_capacity is purely computed; it will become negative if more subscriptions are added than expected_capacity — no hard enforcement exists.